transform: Add transform_bounds fast path for 2D_AFFINE transforms
authorTimm Bäder <mail@baedert.org>
Sat, 29 Jun 2019 07:39:20 +0000 (09:39 +0200)
committerTimm Bäder <mail@baedert.org>
Sat, 29 Jun 2019 07:49:38 +0000 (09:49 +0200)
E.g. anything involving a scale. This is important when e.g. scrolling
in the node list in the recorder, which scales every recorded node down
to fit in the list.

gsk/gsktransform.c

index 289e463bb79c8e4aa9a144473e1159fb8b03d3ce..9af2ce352b1737b24a7a421a492b14fa68d514f5 100644 (file)
@@ -1690,11 +1690,26 @@ gsk_transform_transform_bounds (GskTransform          *self,
       }
     break;
 
+    case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
+      {
+        float dx, dy, scale_x, scale_y;
+
+        gsk_transform_to_affine (self, &scale_x, &scale_y, &dx, &dy);
+
+        *out_rect = *rect;
+        out_rect->origin.x *= scale_x;
+        out_rect->origin.y *= scale_y;
+        out_rect->size.width *= scale_x;
+        out_rect->size.height *= scale_y;
+        out_rect->origin.x += dx;
+        out_rect->origin.y += dy;
+      }
+    break;
+
     case GSK_TRANSFORM_CATEGORY_UNKNOWN:
     case GSK_TRANSFORM_CATEGORY_ANY:
     case GSK_TRANSFORM_CATEGORY_3D:
     case GSK_TRANSFORM_CATEGORY_2D:
-    case GSK_TRANSFORM_CATEGORY_2D_AFFINE:
     default:
       {
         graphene_matrix_t mat;